-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Add option for -nolibc in Driver/ToolChains/Baremetal.cpp #145700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Some tests in LLVM-libc require this flag, so compiler-rt is still linked in, but not the C library. With this change, it will not be ignored. Minor changes: clang-format
|
@llvm/pr-subscribers-clang Author: William Huynh (saturn691) ChangesSome tests in LLVM-libc require this flag, so compiler-rt is still linked in, but not the C library. With this change, it will not be ignored. Minor changes: clang-format Full diff: https://github.com/llvm/llvm-project/pull/145700.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index d8168ed15febd..b87427110d7de 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -339,15 +339,15 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
};
switch (GetCXXStdlibType(DriverArgs)) {
- case ToolChain::CST_Libcxx: {
- SmallString<128> P(D.Dir);
- llvm::sys::path::append(P, "..", "include");
- AddCXXIncludePath(P);
- break;
- }
- case ToolChain::CST_Libstdcxx:
- // We only support libc++ toolchain installation.
- break;
+ case ToolChain::CST_Libcxx: {
+ SmallString<128> P(D.Dir);
+ llvm::sys::path::append(P, "..", "include");
+ AddCXXIncludePath(P);
+ break;
+ }
+ case ToolChain::CST_Libstdcxx:
+ // We only support libc++ toolchain installation.
+ break;
}
std::string SysRoot(computeSysRoot());
@@ -498,7 +498,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
AddRunTimeLibs(TC, D, CmdArgs, Args);
- CmdArgs.push_back("-lc");
+ if (!Args.hasArg(options::OPT_nolibc)) {
+ CmdArgs.push_back("-lc");
+ }
}
if (D.isUsingLTO())
|
|
@llvm/pr-subscribers-clang-driver Author: William Huynh (saturn691) ChangesSome tests in LLVM-libc require this flag, so compiler-rt is still linked in, but not the C library. With this change, it will not be ignored. Minor changes: clang-format Full diff: https://github.com/llvm/llvm-project/pull/145700.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index d8168ed15febd..b87427110d7de 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -339,15 +339,15 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
};
switch (GetCXXStdlibType(DriverArgs)) {
- case ToolChain::CST_Libcxx: {
- SmallString<128> P(D.Dir);
- llvm::sys::path::append(P, "..", "include");
- AddCXXIncludePath(P);
- break;
- }
- case ToolChain::CST_Libstdcxx:
- // We only support libc++ toolchain installation.
- break;
+ case ToolChain::CST_Libcxx: {
+ SmallString<128> P(D.Dir);
+ llvm::sys::path::append(P, "..", "include");
+ AddCXXIncludePath(P);
+ break;
+ }
+ case ToolChain::CST_Libstdcxx:
+ // We only support libc++ toolchain installation.
+ break;
}
std::string SysRoot(computeSysRoot());
@@ -498,7 +498,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
AddRunTimeLibs(TC, D, CmdArgs, Args);
- CmdArgs.push_back("-lc");
+ if (!Args.hasArg(options::OPT_nolibc)) {
+ CmdArgs.push_back("-lc");
+ }
}
if (D.isUsingLTO())
|
|
The change LGTM. Please just fix a typo in the PR description: "requre" |
vhscampos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from my side.
|
@petrhosek ping |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/24419 Here is the relevant piece of the build log for the reference |
Some tests in LLVM-libc require this flag (#145349), which requires compiler-rt to be linked in, but not the C library. With this change, the
-nolibcflag will not be ignored.